package com.fenghongzhang.day012;

import androidx.appcompat.app.AppCompatActivity;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;

import android.app.AlertDialog;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;

public class Main2Activity extends AppCompatActivity {

    private LocalBroadcastManager instance;
    private MyReceiver5 myReceiver5;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

         instance = LocalBroadcastManager.getInstance(this);


        myReceiver5 = new MyReceiver5();
        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction("com.feng5");
        instance.registerReceiver(myReceiver5,intentFilter);


        Intent intent = new Intent();
        intent.setAction("com.feng5");
        instance.sendBroadcast(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        instance.unregisterReceiver(myReceiver5);
    }
}
